import { Req, type Resp } from '@/utils/request'

// 获取角色列表
export function getRoleList(page: {
  pageSize: number
  pageNum: number
}): Promise<Resp<PageInfo<Role>>> {
  return Req.$get<PageInfo<Role>>('/system/role/list', page)
}

// 新增角色
export function addRole(role: Role): Promise<Resp<any>> {
  return Req.$post<any>('/system/role/add', role)
}

// 更新角色
export function updateRole(role: Role): Promise<Resp<any>> {
  return Req.$put<any>('/system/role/update', role)
}

// 更新角色
export function deleteRole(id: number): Promise<Resp<any>> {
  return Req.$delete<any>('/system/role/delete', {}, { id })
}

// 获取关联
export function getRelation(id: number): Promise<Resp<number[]>> {
  return Req.$get<number[]>('/system/role/getRelation', { id })
}

// 获取菜单简要
export function getMenuConcise(): Promise<Resp<Menu[]>> {
  return Req.$get<Menu[]>('/system/role/getMenuConcise')
}

// 更新菜单关联
export function updateRelation(roleId: number, menuIds: number[]): Promise<Resp<any>> {
  return Req.$post<any>('/system/role/updateRelation', {}, { roleId, menuIds })
}
